import 'package:flutter/material.dart';
import 'package:shop/src/r.dart';


/// 字体资源
class RTextStyle {
  /// 一级标题字体
  TextStyle get primary => TextStyle(color: R.color.subtitle, fontSize: 18, fontWeight: FontWeight.bold);

  /// 二级标题字体
  TextStyle get secondary => TextStyle(color: R.color.title, fontSize: 16, fontWeight: FontWeight.bold);

  /// 三级标题字体
  TextStyle get tertiary => TextStyle(color: R.color.title, fontSize: 12, fontWeight: FontWeight.w500);

  // ---------- 定义的颜色对应的字体样式 ---------- //

  /// RTextStyle: 自定义 - normal
  TextStyle custom(double size, {Color? color}) {
    return TextStyle(color: color, fontSize: size, fontWeight: FontWeight.w400);
  }

  /// RTextStyle: 自定义 - medium
  TextStyle customMd(double size, {Color? color}) {
    return TextStyle(color: color, fontSize: size, fontWeight: FontWeight.w500);
  }

  /// RTextStyle: 自定义 - bold
  TextStyle customBl(double size, {Color? color}) {
    return TextStyle(color: color, fontSize: size, fontWeight: FontWeight.w700);
  }

  /// RTextStyle: 白色 - normal
  TextStyle white(double size) {
    return TextStyle(color: Colors.white, fontSize: size, fontWeight: FontWeight.w400);
  }

  /// RTextStyle: 白色 - medium
  TextStyle whiteMd(double size) {
    return TextStyle(color: Colors.white, fontSize: size, fontWeight: FontWeight.w500);
  }

  /// RTextStyle: 白色 - bold
  TextStyle whiteBl(double size) {
    return TextStyle(color: Colors.white, fontSize: size, fontWeight: FontWeight.w700);
  }

  /// RTextStyle: 主色调 - normal
  TextStyle main(double size) {
    return TextStyle(color: R.color.primary, fontSize: size, fontWeight: FontWeight.w400);
  }

  /// RTextStyle: 主色调 - medium
  TextStyle mainMd(double size) {
    return TextStyle(color: R.color.primary, fontSize: size, fontWeight: FontWeight.w500);
  }

  /// RTextStyle: 主色调 - bold
  TextStyle mainBl(double size) {
    return TextStyle(color: R.color.primary, fontSize: size, fontWeight: FontWeight.w700);
  }

  /// RTextStyle: 标题色 - normal
  TextStyle title(double size) {
    return TextStyle(color: R.color.title, fontSize: size, fontWeight: FontWeight.w400);
  }

  /// RTextStyle: 标题色 - medium
  TextStyle titleMd(double size) {
    return TextStyle(color: R.color.title, fontSize: size, fontWeight: FontWeight.w500);
  }

  /// RTextStyle: 标题色 - bold
  TextStyle titleBl(double size) {
    return TextStyle(color: R.color.title, fontSize: size, fontWeight: FontWeight.w700);
  }

  /// RTextStyle: 副标题色 - normal
  TextStyle subtitle(double size) {
    return TextStyle(color: R.color.subtitle, fontSize: size, fontWeight: FontWeight.w400);
  }

  /// RTextStyle: 副标题色 - medium
  TextStyle subtitleMd(double size) {
    return TextStyle(color: R.color.subtitle, fontSize: size, fontWeight: FontWeight.w500);
  }

  /// RTextStyle: 副标题色 - bold
  TextStyle subtitleBl(double size) {
    return TextStyle(color: R.color.subtitle, fontSize: size, fontWeight: FontWeight.w700);
  }

  /// RTextStyle: 内容色 - normal
  TextStyle content(double size) {
    return TextStyle(color: R.color.content, fontSize: size, fontWeight: FontWeight.w400);
  }

  /// RTextStyle: 内容色 - medium
  TextStyle contentMd(double size) {
    return TextStyle(color: R.color.content, fontSize: size, fontWeight: FontWeight.w500);
  }

  /// RTextStyle: 内容色 - bold
  TextStyle contentBl(double size) {
    return TextStyle(color: R.color.content, fontSize: size, fontWeight: FontWeight.w700);
  }

  /// RTextStyle: 辅助色 - normal
  TextStyle help(double size) {
    return TextStyle(color: R.color.help, fontSize: size, fontWeight: FontWeight.w400);
  }

  /// RTextStyle: 辅助色 - medium
  TextStyle helpMd(double size) {
    return TextStyle(color: R.color.help, fontSize: size, fontWeight: FontWeight.w500);
  }

  /// RTextStyle: 辅助色 - bold
  TextStyle helpBl(double size) {
    return TextStyle(color: R.color.help, fontSize: size, fontWeight: FontWeight.w700);
  }

  // ---------- 圆角 ---------- //

  /// RTextStyle: 全部圆角
  BorderRadius radius(double val) {
    return BorderRadius.all(Radius.circular(val));
  }

  /// RTextStyle: 独立圆角
  BorderRadius radiusOnly({double? topLeft, double? topRight, double? bottomLeft, double? bottomRight}) {
    return BorderRadius.only(
      topLeft: topLeft != null ? Radius.circular(topLeft) : Radius.zero,
      topRight: topRight != null ? Radius.circular(topRight) : Radius.zero,
      bottomLeft: bottomLeft != null ? Radius.circular(bottomLeft) : Radius.zero,
      bottomRight: bottomRight != null ? Radius.circular(bottomRight) : Radius.zero,
    );
  }

  /// RTextStyle: 全部边框
  Border border({Color? color, double width = 1}) {
    return Border.all(color: color ?? R.color.line, width: width);
  }

  /// RTextStyle: 独立边框
  Border borderOnly({
    bool left = false,
    bool top = false,
    bool right = false,
    bool bottom = false,
    Color? color,
    double width = 1,
  }) {
    return Border(
      left: left ? BorderSide(color: color ?? R.color.line, width: width) : BorderSide.none,
      top: top ? BorderSide(color: color ?? R.color.line, width: width) : BorderSide.none,
      right: right ? BorderSide(color: color ?? R.color.line, width: width) : BorderSide.none,
      bottom: bottom ? BorderSide(color: color ?? R.color.line, width: width) : BorderSide.none,
    );
  }

  /// RTextStyle: 默认阴影
  BoxShadow shadow({
    Color? color,
    Offset? offset,
    double blurRadius = 5.0,
    double spreadRadius = 0.0,
    BlurStyle blurStyle = BlurStyle.normal,
  }) {
    return BoxShadow(
      color: color ?? Colors.black.withOpacity(0.1),
      offset: offset ?? const Offset(0, 3),
      blurRadius: blurRadius,
      spreadRadius: spreadRadius,
      blurStyle: blurStyle,
    );
  }
}
